package com.sgb.kjwl.aroute;

import android.app.Activity;
import android.content.Context;

import androidx.fragment.app.Fragment;

import com.alibaba.android.arouter.facade.annotation.Route;

import com.sgb.alimaplibrary.MapLocationTools;
import com.swgk.core.util.UserOperating;
import com.sgb.kjwl.view.ui.activity.MainActivity;
import com.sgb.kjwl.view.ui.activity.manage.ShopInfoForCompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.packers.TeamOfferDetailActivity;
import com.sgb.kjwl.view.ui.activity.self.ApprovalManagerActvity;
import com.sgb.kjwl.view.ui.activity.self.logistics.QuotedOwnerActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.activity.transport.driver.goods.FreightPrjDetailActivity;
import com.sgb.kjwl.view.ui.activity.transport.driver.goods.GeneralPrjDetailActivity;
import com.sgb.kjwl.view.ui.fragment.HomeFragment3;
import com.swgk.core.base.aroute.AppRouteConstant;
import com.swgk.core.base.aroute.SimpleARouteCallback;
import com.swgk.core.base.aroute.provider.OtherProvider;
import com.im.immodel.IMUtils;

@Route(path = AppRouteConstant.HuiYuan.ROUTER_PATH_OTHER, name = "其他")
public class OtherProviderImpl implements OtherProvider {

    @Override
    public void init(Context context) {

    }

    @Override
    public void startWebsiteInfoActivity(Context context, String websiteNo, int websiteType) {
        WebsiteInfoActivity.start(context, websiteNo, websiteType);
    }

    @Override
    public void startShopInfoForCompanyTradesActivity(Context context, String supplierId, String companyNo, int i, int i1) {
        ShopInfoForCompanyTradesActivity.startAct(context, supplierId, companyNo, i, i1);
    }

    @Override
    public void startVerificationCodeLoginActivity3(Context context, int jump_address) {
        VerificationCodeLoginActivity.start(context, jump_address);
    }

    @Override
    public void jumpSelfCenter(Fragment fragment) {
        Fragment parentFragment = fragment.getParentFragment();
        if (parentFragment instanceof HomeFragment3) {
            MainActivity mainActivity = ((HomeFragment3) fragment.getParentFragment()).getMainActivity();
            if (mainActivity != null) {
                mainActivity.tabSelfClick(); // // 跳转个人中心
            }
        }
    }

    @Override
    public void startTeamOfferDetailActivity(Activity context, String teamNo) {
        TeamOfferDetailActivity.start(context, teamNo);
    }

    @Override
    public void startApprovalManagerActvity(Activity activity, int i) {
        ApprovalManagerActvity.start(activity, 1);
    }

    @Override
    public void startNimUIKit(Activity memberCompanyWebActivity, String imAccount) {
//        NimUIKit.startP2PSession(memberCompanyWebActivity, imAccount);
        IMUtils.getInstance().buildSingleTalking(imAccount);
    }

    @Override
    public void getLocalPosition(Context context, SimpleARouteCallback callback) {
        MapLocationTools mapLocationTools = new MapLocationTools(context);
        mapLocationTools.initLocation(false);
        mapLocationTools.setLocationListener(new MapLocationTools.LocationListener() {
            @Override
            public void getLocationListener(String address, Double Longitude, Double Latitude) {
                String longitude = String.valueOf(Longitude);
                String latitude = String.valueOf(Latitude);
                callback.onResult(longitude, latitude);
            }
        });
        mapLocationTools.startLocation();
    }

    @Override
    public void startQuotedOwnerActivity(Context context, String no) {
        // 报价单位 —— 竞价货源  （货主视角）
        QuotedOwnerActivity.start(context, no);
    }

    @Override
    public String getTeamOrCompanyNameNo() {
        return UserOperating.getInstance().getTeamOrCompanyNameNo();
    }

    @Override
    public String getTeamOrCompanyName() {
        return UserOperating.getInstance().getTeamOrCompanyName();
    }

    @Override
    public String getUserNo() {
        return UserOperating.getInstance().getUserNo();
    }

    @Override
    public void startFreightPrjDetailActivity(Context context, String sourceNo, boolean isOrder, boolean position) {
        FreightPrjDetailActivity.start(context, sourceNo, isOrder, position);

    }

    @Override
    public void startGeneralPrjDetailActivity(Context context, String sourceNo, int goodstype, boolean position) {
        GeneralPrjDetailActivity.start(context, sourceNo, goodstype, position);

    }
}
